# coding:utf-8
import xlrd
import xlsxwriter
import random
import requests
import ssl
import urllib
import urllib.request

def create_saiche_data():
    list = [1,2,3,4,5,6,7,8,9,10]
    random.shuffle(list)
    #print(list)
    return list

def create_exl_data(num):
    workbook = xlsxwriter.Workbook(u'd:/work/test/test.xlsx')

    worksheet = workbook.add_worksheet()  # 创建一个表

    for i in range(0, num):
        t = create_saiche_data()
        worksheet.write_row(i, 0, t)  # write_row(行,列,t)

    workbook.close()
    pass

def analyze_exl_process():
    workbook = xlrd.open_workbook(u'd:/work/test/test.xlsx')
    sheet1_name = workbook.sheet_names()[0]
    print(sheet1_name)
    sheet1 = workbook.sheet_by_name(sheet1_name)
    rows = sheet1.row_values(3)  # 获取第四行内容
    cols = sheet1.col_values(1)  # 获取第三列内容

    #print(cols)
    print(len(cols))

    ok = 0
    max = 0
    list = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    for i in range(0,len(cols)):
        #print(cols[i])
        if cols[i] <= 5:
            print("X")
            ok += 1
            if ok  > max:
                print(max)
                max = ok
        else:
            print("D")
            for i in range(0,len(list)):
                if ok == i:
                    list[i] += 1
                    break
            ok = 0


    print(max)
    print(list)
    for i in range(0, len(list)):
        print(list[i]/len(cols))
def test():

    #for i in range(1,100):
    #   create_saiche_data()
    #create_exl_data(1440*365*1)#创建测试数据
    analyze_exl_process()
def getHtml(url):
    page = urllib.request.urlopen(url)
    html = page.read()
    html = html.decode('utf-8')
    return html


def getImg(html):
    reg = r'<p class="img_title">(.*)</p>'
    img_title = re.compile(reg)
    imglist = re.findall(img_title, html)
    return imglist

def conncet_server():
    #url = "https://www.kjw686.com/mobile/#/game/pk10/jspk10/1"

    url = "https://www.kjw686.com/"
    data = urllib.request.urlopen(url).read()
    data = data.decode('UTF-8')
    print(data)
if __name__ == '__main__':
    #test()
    conncet_server()